import { put, takeEvery } from 'redux-saga/effects'
import { GET_LIST_DATA } from "./actionTypes";
import { getInitListAction } from './actionCreators'
import axios from 'axios'

function* getListData() {
    try{
        const res = yield axios.get('/list.json')
        const action = getInitListAction(res.data)
        yield put(action)
    }catch(e){
        console.log('失败')
    }
}

function* mySaga() {
    yield takeEvery(GET_LIST_DATA, getListData);
}

export default mySaga;